﻿using System;
using System.Configuration;

using BizElements.Web;
using BizElements.Web.UI;

namespace MySolution.Web
{
    public partial class _Default : System.Web.UI.Page
    {
        /// <summary>~/Default.aspx</summary>
        public const string RelativeUrl = "~/Default.aspx";

        /// <summary>Indicates whether framesets are configured as web layout in config file.</summary>
        public static bool UseFrameset = ConfigurationManager.AppSettings["WebLayout"] == "frameset";

        /// <summary>3 frames: toolbar, menu and intro form.</summary>
        const string FramesetHtml = 
            "<frameset rows=\"85,*\" frameborder=\"no\">" + 
            "  <frame name=\"toolbar\" src=\"ToolbarFrm.aspx\" scrolling=\"no\" />" + 
            "  <frameset id=\"frameset_Content\" cols=\"250,*\">" + 
            "    <frame name=\"leftMenu\" src=\"MenuFrm.aspx\">" + 
            "    <frame name=\"currentForm\" src=\"IntroFrm.aspx\">" + 
            "  </frameset>" + 
            "</frameset>";

        /// <summary>Redirects to initial view: login form or intro form.</summary>
        protected void Page_Load(object sender, EventArgs e)
        {
            if (UserSession.Actor == null)
                CommonRedirects.ToLoginForm();
            else if (UseFrameset)
                Response.Write(FramesetHtml);
            else
                Response.Redirect("~/IntroFrm.aspx");
        }
    }
}
